/**
 * 当前这个index.js文件是用来做统一发送请求的
 * 这里暴露了很多的请求方法
 *
 * 13211223344
 * 13311223344 aaa123
 */

// 0. 引入二次封装的axios对象
import ajax from './ajax'
// import request from './ajax';
import mockAjax from './mockAjax'

// 1. 封装获取三级导航的接口函数
// export const reqGetCategoryListData = (url) => {
//   return ajax.get(url)0
// }

export const reqGetCategoryListData = () => ajax.get('/product/getBaseCategoryList')

// 2. 获取轮播图时的接口函数
export const reqGetBannerListData = () => mockAjax.get('/bannerList')

// 3. 获取楼层数据的接口函数
export const reqGetFloorsListData = () => mockAjax.get('/floorsList')

// 4. 获取search页面的相关数据的接口函数
export const reqGetSearchGoodsInfoData = (searchParams) => ajax.post('/list', searchParams)

// 5. 获取商品详情数据
export const reqGetGoodsDetailInfoData = (skuId) => ajax.get(`/item/${skuId}`)

// 6. 添加或者更新商品 到购物车中
export const reqAddOrUpdateSkuInfoToShopCart = (skuId, skuNum) => ajax.post(`/cart/addToCart/${skuId}/${skuNum}`)

// 7. 获取购物车中的数据
export const reqGetShopCartListData = () => ajax.get('/cart/cartList')

// 8. 更改购物车商品的选中状态
export const reqChangeShopCartInfoState = (skuID, isChecked) => ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

// 9. 批量更新购物车中的商品选中状态
// export const reqChangeAllShopCartInfoState = (skuIdList, isChecked) => ajax.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)

// export const reqChangeAllShopCartInfoState = (skuIdList, isChecked) => {
//   return ajax({
//     url: `/cart/batchCheckCart/${isChecked}`,
//     method: 'post',
//     data: skuIdList
//   });
// };

// 当箭头函数的里面只有一行代码的时候，是可以省略return和{}
export const reqChangeAllShopCartInfoState = (skuIdList, isChecked) =>
  ajax({
    url: `/cart/batchCheckCart/${isChecked}`,
    method: 'post',
    data: skuIdList
  })

// 10. 删除购物车中的一条商品数据
export const reqDelOneShopCartInfo = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)

// 11. 批量删除购物车中的多条数据
// export const reqDelSelectedShopCartInfo = skuIdList => ajax.delete('/cart/batchDeleteCart', { data: skuIdList })
export const reqDelSelectedShopCartInfo = (skuIdList) => ajax.post('/cart/batchDeleteCart', skuIdList)

// 12. 获取trade页面中的数据
export const reqGetTradeListData = () => ajax.get('/order/auth/trade')

// 13. 获取手机验证码
export const reqGetPhoneVerifyCode = (phone) => ajax.get(`/user/passport/sendCode/${phone}`)

// 14. 注册用户
export const reqUserRegister = (user) => ajax.post(`/user/passport/register`, user)

// 15. 账户登陆
export const reqUserLogin = (user) => ajax.post('/user/passport/login', user)

// 16 登出
export const reqLogout = () => ajax.get('/user/passport/logout')
//16. 获取邮寄地址
//reqUserAddressList
// export const reqUserAddressList = ()=>{
//   ajax.get('/user/userAddress/auth/findUserAddressList')
// }

// 17.获取订单交易页数据
export const reqTradeInfoData = () => ajax.get('/order/auth/trade')

// 18. 提交订单
export const reqSubmitTradeOrder = (tradeNo, params) => ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, params)

// 19. 获取订单支付信息 也就是支付链接 用支付链接再结合插件实现的二维码图片
export const reqGetOrderPayment = (orderId) => ajax.get(`/payment/weixin/createNative/${orderId}`)

// 19. 获得订单支付信息  也就是获取支付二维码
export const reqGetPayQRcode = (orderId) => ajax.get(`/api/payment/weixin/createNative/${orderId}`)

// 20. 查询支付的订单状态  是否支付成功
export const reqQueryPayStatus = (orderId) => ajax.get(`/payment/weixin/queryPayStatus/${orderId}`)
